﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AD.Model;
using AD.DAL;
using System.Data;

namespace AD.BLL
{
    public class PayTradeBLL
    {
        public static List<PayTradeMod> QueryByPage(string filter, int pageSize, int index, out int maxcount)
        {
            return PayTradeDAL.QueryByPage(filter, pageSize, index, out  maxcount);
        }
        public static PayTradeMod QueryByTradeNo(string trade_no)
        {
            return PayTradeDAL.QueryByTradeNo(trade_no);
        }
        public static int Count(string filter)
        {
            return PayTradeDAL.Count(filter);
        }

        public static int Insert(PayTradeMod payTrade)
        {
            return PayTradeDAL.Insert(payTrade);
        }

        public static PayTradeMod CheckPayTrade(string trade_no)
        {
            return PayTradeDAL.CheckPayTrade(trade_no);
        }

        public static PayTradeMod QueryFrist(string filter)
        {
            return PayTradeDAL.QueryFrist(filter);
        }

        public static DataTable QueryFilterToTable(string filter)
        {
            return PayTradeDAL.QueryFilterToTable(filter);
        }

        public static List<PayTradeMod> QueryFilterToList(string filter)
        {
            return PayTradeDAL.QueryFilterToList(filter);
        }
        public static int UpdatePaySuccessStatus(string trade_no, bool flag)
        {
            return PayTradeDAL.UpdatePaySuccessStatus(trade_no, flag);
        }
        public static int UpdatePaySuccessStatus(string trade_no)
        {
            return UpdatePaySuccessStatus(trade_no, true);
            //PayTradeMod payTrade = QueryFrist("Out_Trade_No='" + trade_no + "'");
            //if (!payTrade.Status)
            //{
            //    return PayTradeDAL.UpdatePaySuccessStatus(trade_no);
            //    //if (PayTradeDAL.UpdatePaySuccessStatus(trade_no) > 0)
            //    //    return UserBLL.UpdateBalancePoint(payTrade.UserId, payTrade.RewardPoints + payTrade.GiftPoints + payTrade.Rechargepoints);
            //}
            //return 0;
        }

        public static PayTradeMod CheckIP(PayTradeMod pay) {
            return PayTradeDAL.CheckIP(pay);
        }
        public static int UpdateInMoneyStatus(string trade_no)
        {
            return PayTradeDAL.UpdateInMoneyStatus(trade_no);
        }
       
        public static int DeleteById(string tradeNo)
        {
            return PayTradeDAL.DeleteById(tradeNo);
        }

        public static int Delete(string filter)
        {
            return PayTradeDAL.Delete(filter);
        }

        public static int Delete(PayTradeMod payTrade)
        {
            return Delete(payTrade.Out_Trade_No);
        }
    }
}